using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
    /// <summary> 
    ///Author: nnamthach@gmail.com 
    /// <summary>

    public class SNSInfo
    {
        #region Local Variable
        public enum Field
        {
            TVC_DB,
            LOOKUP,
            CREATEDBY,
            MODIFIEDBY,
            CREATEDDATE,
            MODIFIEDDATE,
            CODE,
            DESCRIPTION,
            LEDGER,
            MODE,
            NEXT_NUMBER,
            FORMAT,
            CURRENTDATE,
            ResetMonth
        }
        private String _TVC_DB;
        private String _LOOKUP;
        private String _CREATEDBY;
        private String _MODIFIEDBY;
        private Int32 _CREATEDDATE;
        private Int32 _MODIFIEDDATE;
        private String _CODE;
        private String _DESCRIPTION;
        private String _LEDGER;
        private String _MODE;
        private String _NEXT_NUMBER;
        private String _FORMAT;
        private String _CURRENTDATE;
        private int _ResetMonth;

        public String TVC_DB { get { return _TVC_DB; } set { _TVC_DB = value; } }
        public String LOOKUP { get { return _LOOKUP; } set { _LOOKUP = value; } }
        public String CREATEDBY { get { return _CREATEDBY; } set { _CREATEDBY = value; } }
        public String MODIFIEDBY { get { return _MODIFIEDBY; } set { _MODIFIEDBY = value; } }
        public Int32 CREATEDDATE { get { return _CREATEDDATE; } set { _CREATEDDATE = value; } }
        public Int32 MODIFIEDDATE { get { return _MODIFIEDDATE; } set { _MODIFIEDDATE = value; } }
        public String CODE { get { return _CODE; } set { _CODE = value; } }
        public String DESCRIPTION { get { return _DESCRIPTION; } set { _DESCRIPTION = value; } }
        public String LEDGER { get { return _LEDGER; } set { _LEDGER = value; } }
        public String MODE { get { return _MODE; } set { _MODE = value; } }
        public String NEXT_NUMBER { get { return _NEXT_NUMBER; } set { _NEXT_NUMBER = value; } }
        public String FORMAT { get { return _FORMAT; } set { _FORMAT = value; } }
        public String CURRENTDATE { get { return _CURRENTDATE; } set { _CURRENTDATE = value; } }
        public int ResetMonth { get { return _ResetMonth; } set { _ResetMonth = value; } }
        #endregion LocalVariable

        #region Constructor
        public SNSInfo()
        {
            _TVC_DB = "";
            _LOOKUP = "";
            _CREATEDBY = "";
            _MODIFIEDBY = "";
            _CREATEDDATE = 0;
            _MODIFIEDDATE = 0;
            _CODE = "";
            _DESCRIPTION = "";
            _LEDGER = "";
            _MODE = "";
            _NEXT_NUMBER = "";
            _FORMAT = "";
            _CURRENTDATE = "";
            _ResetMonth = 0;
        }
        public SNSInfo(
        String TVC_DB,
        String LOOKUP,
        String CREATEDBY,
        String MODIFIEDBY,
        Int32 CREATEDDATE,
        Int32 MODIFIEDDATE,
        String CODE,
        String DESCRIPTION,
        String LEDGER,
        String MODE,
        String NEXT_NUMBER,
        String FORMAT,
        String CURRENTDATE,
            int ResetMonth
        )
        {
            _TVC_DB = TVC_DB;
            _LOOKUP = LOOKUP;
            _CREATEDBY = CREATEDBY;
            _MODIFIEDBY = MODIFIEDBY;
            _CREATEDDATE = CREATEDDATE;
            _MODIFIEDDATE = MODIFIEDDATE;
            _CODE = CODE;
            _DESCRIPTION = DESCRIPTION;
            _LEDGER = LEDGER;
            _MODE = MODE;
            _NEXT_NUMBER = NEXT_NUMBER;
            _FORMAT = FORMAT;
            _CURRENTDATE = CURRENTDATE;
            _ResetMonth = ResetMonth;
        }
        public SNSInfo(DataRow dr)
        {
            if (dr != null)
            {
                _TVC_DB = dr[Field.TVC_DB.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.TVC_DB.ToString()]);
                _LOOKUP = dr[Field.LOOKUP.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.LOOKUP.ToString()]);
                _CREATEDBY = dr[Field.CREATEDBY.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.CREATEDBY.ToString()]);
                _MODIFIEDBY = dr[Field.MODIFIEDBY.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.MODIFIEDBY.ToString()]);
                _CREATEDDATE = dr[Field.CREATEDDATE.ToString()] == DBNull.Value ? 0 : Convert.ToInt32(dr[Field.CREATEDDATE.ToString()]);
                _MODIFIEDDATE = dr[Field.MODIFIEDDATE.ToString()] == DBNull.Value ? 0 : Convert.ToInt32(dr[Field.MODIFIEDDATE.ToString()]);
                _CODE = dr[Field.CODE.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.CODE.ToString()]);
                _DESCRIPTION = dr[Field.DESCRIPTION.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.DESCRIPTION.ToString()]);
                _LEDGER = dr[Field.LEDGER.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.LEDGER.ToString()]);
                _MODE = dr[Field.MODE.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.MODE.ToString()]);
                _NEXT_NUMBER = dr[Field.NEXT_NUMBER.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.NEXT_NUMBER.ToString()]);
                _FORMAT = dr[Field.FORMAT.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.FORMAT.ToString()]);
                _CURRENTDATE = dr[Field.CURRENTDATE.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.CURRENTDATE.ToString()]);
                _ResetMonth = dr[Field.ResetMonth.ToString()] == DBNull.Value || dr[Field.ResetMonth.ToString()] == "" ? 0 : Convert.ToInt32(dr[Field.ResetMonth.ToString()]);
                
            }
        }
        public SNSInfo(DataRowView dr)
        {
            if (dr != null)
            {
                _TVC_DB = dr[Field.TVC_DB.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.TVC_DB.ToString()]);
                _LOOKUP = dr[Field.LOOKUP.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.LOOKUP.ToString()]);
                _CREATEDBY = dr[Field.CREATEDBY.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.CREATEDBY.ToString()]);
                _MODIFIEDBY = dr[Field.MODIFIEDBY.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.MODIFIEDBY.ToString()]);
                _CREATEDDATE = dr[Field.CREATEDDATE.ToString()] == DBNull.Value ? 0 : Convert.ToInt32(dr[Field.CREATEDDATE.ToString()]);
                _MODIFIEDDATE = dr[Field.MODIFIEDDATE.ToString()] == DBNull.Value ? 0 : Convert.ToInt32(dr[Field.MODIFIEDDATE.ToString()]);
                _CODE = dr[Field.CODE.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.CODE.ToString()]);
                _DESCRIPTION = dr[Field.DESCRIPTION.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.DESCRIPTION.ToString()]);
                _LEDGER = dr[Field.LEDGER.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.LEDGER.ToString()]);
                _MODE = dr[Field.MODE.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.MODE.ToString()]);
                _NEXT_NUMBER = dr[Field.NEXT_NUMBER.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.NEXT_NUMBER.ToString()]);
                _FORMAT = dr[Field.FORMAT.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.FORMAT.ToString()]);
                _CURRENTDATE = dr[Field.CURRENTDATE.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.CURRENTDATE.ToString()]);
                _ResetMonth = dr[Field.ResetMonth.ToString()] == DBNull.Value || dr[Field.ResetMonth.ToString()] == "" ? 0 : Convert.ToInt32(dr[Field.ResetMonth.ToString()]);
            }
        }
        public SNSInfo(SNSInfo objEntr)
        {
            _TVC_DB = objEntr.TVC_DB;
            _LOOKUP = objEntr.LOOKUP;
            _CREATEDBY = objEntr.CREATEDBY;
            _MODIFIEDBY = objEntr.MODIFIEDBY;
            _CREATEDDATE = objEntr.CREATEDDATE;
            _MODIFIEDDATE = objEntr.MODIFIEDDATE;
            _CODE = objEntr.CODE;
            _DESCRIPTION = objEntr.DESCRIPTION;
            _LEDGER = objEntr.LEDGER;
            _MODE = objEntr.MODE;
            _NEXT_NUMBER = objEntr.NEXT_NUMBER;
            _FORMAT = objEntr.FORMAT;
            _CURRENTDATE = objEntr.CURRENTDATE;
            _ResetMonth = objEntr._ResetMonth;
        }
        #endregion Constructor

        #region InitTable
        public static DataTable ToDataTable()
        {
            DataTable dt = new DataTable("SNS");
            dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.TVC_DB.ToString(), typeof(String)),
				new DataColumn(Field.LOOKUP.ToString(), typeof(String)),
				new DataColumn(Field.CREATEDBY.ToString(), typeof(String)),
				new DataColumn(Field.MODIFIEDBY.ToString(), typeof(String)),
				new DataColumn(Field.CREATEDDATE.ToString(), typeof(Int32)),
				new DataColumn(Field.MODIFIEDDATE.ToString(), typeof(Int32)),
				new DataColumn(Field.CODE.ToString(), typeof(String)),
				new DataColumn(Field.DESCRIPTION.ToString(), typeof(String)),
				new DataColumn(Field.LEDGER.ToString(), typeof(String)),
				new DataColumn(Field.MODE.ToString(), typeof(String)),
				new DataColumn(Field.NEXT_NUMBER.ToString(), typeof(String)),
				new DataColumn(Field.FORMAT.ToString(), typeof(String)),
				new DataColumn(Field.CURRENTDATE.ToString(), typeof(String)),
                new DataColumn(Field.ResetMonth.ToString(), typeof(String))
			});
            return dt;
        }
        public DataRow ToDataRow(DataTable dt)
        {
            DataRow row = dt.NewRow();
            row[Field.TVC_DB.ToString()] = _TVC_DB;
            row[Field.LOOKUP.ToString()] = _LOOKUP;
            row[Field.CREATEDBY.ToString()] = _CREATEDBY;
            row[Field.MODIFIEDBY.ToString()] = _MODIFIEDBY;
            row[Field.CREATEDDATE.ToString()] = _CREATEDDATE;
            row[Field.MODIFIEDDATE.ToString()] = _MODIFIEDDATE;
            row[Field.CODE.ToString()] = _CODE;
            row[Field.DESCRIPTION.ToString()] = _DESCRIPTION;
            row[Field.LEDGER.ToString()] = _LEDGER;
            row[Field.MODE.ToString()] = _MODE;
            row[Field.NEXT_NUMBER.ToString()] = _NEXT_NUMBER;
            row[Field.FORMAT.ToString()] = _FORMAT;
            row[Field.CURRENTDATE.ToString()] = _CURRENTDATE;
            row[Field.ResetMonth.ToString()] = _ResetMonth;
            return row;
        }
        #endregion InitTable
    }
}
